#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include"xh.h"
List createlist() {

	List list = (ptrArraylist)malloc(sizeof(struct sequelist));
	if (list == NULL) {
		perror("malloc");
		return NULL;
	}
	if(list->size ==list->capicity )
	{
		int Newcapicity = list->capicity == 0 ? 4 : 2 * list->capicity;
		List L= realloc(list->arr, Newcapicity * 2 * sizeof(ElementType));

		if (L == NULL) {
			perror("realloc");
			return NULL;
		}
		list->arr = L;
		list->capicity = Newcapicity;
		list->size = 0;
	}
	return list;
}

int isempty(List list) {
	if (list == NULL)
		return ERROR;
	return (list->size == 0);
}

void additemfirst(List list, ElementType x) {
	isempty(list);
	for (int i = list->size; i >0; i--) {
		list->arr[i] = list->arr[i - 1];
	}
	list->arr[0] = x;
	list->size++;
}



void print(List list) {
	int i = 0;
	for (i = 0; i < list->size; i++) {
		printf("%d ", list->arr[i]);
	}
}